import axios from 'axios';
let base = "";
if (process.env.NODE_ENV == 'production') {
  base = window.g.url;
} else if (process.env.NODE_ENV == 'development') {
  base = window.g.url;
}

axios.interceptors.request.use(
  (config) => {
    // let token = Vue.$cookies.get('token');
    config.headers['Access-Control-Allow-Origin'] = '*';
    config.headers['Access-Control-Allow-Methods'] = 'GET,POST,PUT,OPTIONS,DELETE';
    config.headers['Content-Type'] = 'application/json; charset=utf-8';
    return config;
  },
  (err) => {
    return Promise.reject(err);
  }
);

/*详情数据*/
export const checkLikeList = (params) => {
  return axios.post(`${base}/checkLike?pageNum=${params.pagnum}&limit=${params.limit}`, params).then((res) => res.data);
};
//单独搜索
export const checkLikeByKey = (params) => {
  return axios.post(`${base}/checkLikeByKey`, params).then((res) => res.data);
};
//用户注册
export const userRegsit = (params) => {
  return axios.post(`${base}/regsit`, params).then((res) => res.data);
};
//用户登陆
export const userDologin = (params) => {
  return axios.post(`${base}/dologin`, params).then((res) => res.data);
};
//修改用户
export const saveOrUpdateUser = (params) => {
  return axios.post(`${base}/users/saveOrUpdateUser`, params).then((res) => res.data);
};
//购买 //购物车列表
export const saveOrUpdateOrderMore = (params) => {
  return axios.post(`${base}/fruitss/saveOrUpdateOrderMore`, params).then((res) => res.data);
};
//地址列表
export const addressList = (params) => {
  return axios.post(`${base}/address/list/${params}`, params).then((res) => res.data);
};
//地址添加
export const addressInsert = (params) => {
  return axios.post(`${base}/address/insert`, params).then((res) => res.data);
};
//购物车列表
export const fruitssOrderById = (params) => {
  return axios.post(`${base}/fruitss/orderById`, params).then((res) => res.data);
};
//  //购物车删除
export const fruitssDelOrder = (params) => {
  return axios.delete(`${base}/fruitss/delOne/${params}`).then((res) => res.data);
};

